# $Id$
# Contributor: Firmicus <firmicus āt gmx dōt net>
# Maintainer: Rémy Oudompheng <remy@archlinux.org>

pkgname=texlive-htmlxml
pkgver=2016.43769
_revnr=${pkgver#2016.}
pkgrel=1
pkgdesc="TeX Live - Packages to convert LaTeX to XML/HTML, and typeset XML/SGML"
license=('GPL')
arch=(any)
depends=('texlive-core')
groups=('texlive-most')
url='http://tug.org/texlive/'
source=("https://sources.archlinux.org/other/texlive/$pkgname-$pkgver-src.zip"
        "texlive-htmlxml.fmts")
options=('!emptydirs')
sha256sums=('13ee4e43355ad4dcbec2af1bc96d156a5cb7f8432399bb025879619749ad4d3d'
            '5588f95a31ff1ce2b567c686fea27f43b7757582fb8cd2f0294ea161d9df0297')

build() {
   cd "$srcdir"
   for p in *.tar.xz; do
	   bsdtar -xf $p
   done
   rm -rf {tlpkg,doc,source} || true
}

package() {
   install -m755 -d $pkgdir/var/lib/texmf/arch/installedpkgs
   sed -i '/^#/d' CONTENTS
   install -m644 CONTENTS $pkgdir/var/lib/texmf/arch/installedpkgs/${pkgname}_${_revnr}.pkgs
   install -m644 $pkgname.fmts $pkgdir/var/lib/texmf/arch/installedpkgs/

   install -m755 -d $pkgdir/usr/share
   wanteddirs=$(for d in *; do test -d $d && [[ $d != texmf* ]] && echo $d; done) || true
   for dir in $wanteddirs; do
     find $dir -type d -exec install -d -m755 $pkgdir/usr/share/texmf-dist/'{}' \;
     find $dir -type f -exec install -m644 '{}' $pkgdir/usr/share/texmf-dist/'{}' \;
   done
   if [[ -d texmf-dist ]]; then
     find texmf-dist -type d -exec install -d -m755 $pkgdir/usr/share/'{}' \;
     find texmf-dist -type f -exec install -m644 '{}' $pkgdir/usr/share/'{}' \;
   fi
   if [[ -d $pkgdir/usr/share/texmf-dist/scripts ]]; then
     find $pkgdir/usr/share/texmf-dist/scripts -type f -exec chmod a+x '{}' \;
   fi
   install -m755 -d $pkgdir/usr/bin
   ln -s /usr/share/texmf-dist/scripts/lwarp/lwarpmk.lua $pkgdir/usr/bin/lwarpmk
   ln -s /usr/share/texmf-dist/scripts/tex4ht/ht.sh $pkgdir/usr/bin/ht
   ln -s /usr/share/texmf-dist/scripts/tex4ht/htcontext.sh $pkgdir/usr/bin/htcontext
   ln -s /usr/share/texmf-dist/scripts/tex4ht/htlatex.sh $pkgdir/usr/bin/htlatex
   ln -s /usr/share/texmf-dist/scripts/tex4ht/htmex.sh $pkgdir/usr/bin/htmex
   ln -s /usr/share/texmf-dist/scripts/tex4ht/httex.sh $pkgdir/usr/bin/httex
   ln -s /usr/share/texmf-dist/scripts/tex4ht/httexi.sh $pkgdir/usr/bin/httexi
   ln -s /usr/share/texmf-dist/scripts/tex4ht/htxelatex.sh $pkgdir/usr/bin/htxelatex
   ln -s /usr/share/texmf-dist/scripts/tex4ht/htxetex.sh $pkgdir/usr/bin/htxetex
   ln -s /usr/share/texmf-dist/scripts/tex4ht/mk4ht.pl $pkgdir/usr/bin/mk4ht
}
